-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@sveltejs/enhanced-img: Fix client component compilation #11059
Conversation
🦋 Changeset detectedLatest commit: c1ea90a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Thanks for finding and fixing this! It looks to me like this happens on the client-side JS. I can't reproduce it on the SvelteKit site and I'm guessing that may be because we only do manual imports there. I'm really curious why it doesn't happen with manual imports, but does happen when simply sticking the path in the |
Here's the relevant location in Vite: |
Hmm. In #9220 we seem to be forcing relative paths (which was attempted to be changed and then later reverted in #10442). I don't like the API of The We will need a solution like in this PR regardless of whether we can keep Kit in an optimized state because you'll end up with this code when the user sets |
I also really dislike this solution, but given that the alternative is all images being broken on pages with CSR, might it be better to merge this ASAP and then look into performance improvements? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I pushed a couple small changes and filed issues to followup on the rest
In JS files, Vite compiles
__VITE_ASSET_xxx_
to" + new URL("../path", import.meta.url) + "
. This was being inlined directly into the client-side components, meaning the client components were rendering<img src=" + new URL("../path", import.meta.url) + ">
. This fixes that.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.